Unit Tests
- tests a single class
- focuses on single behavior or function
- it drives implementation
- runs in memory (using mocks)
Integration Tests
- tests a system (more whole than unit test)
- focuses on interaction between functions
- catches regressions (in future changes)
- runs in database (uses data access layer)
Due to integration tests being focused on the whole system it will often catch problems that unit tests miss.
Myths about Integration Testing
- They are slow to run
- They are sensitive to change and therefore can break easily
- They are difficult to setup
Integration tests are crucial because it takes data into account. From a user’s point of view, data is their ultimate purpose for using an application and therefore we need to ensure the data access layer is thoroughly tested. Having integration tests there will be less regression and ultimately fewer bugs. This increases velocity, which is contrary to the myth that it slows down development. Having integration tests makes it safer to implement new changes, thereby increasing the resiliency of the overall system.